<?php
require_once("conf/db_connection.php");

$trip_id = $_GET["id"];
$return_str = "";

$query_trip = "SELECT * FROM trip_detail WHERE id='".$trip_id."'";
$result_trip = mysql_query($query_trip) or die("SELECT TRIP DETAIL ".mysql_error());
$row_trip = mysql_fetch_array($result_trip);

$query_truck = "SELECT * FROM truck WHERE id='".$row_trip['truck_id']."'";
$result_truck = mysql_query($query_truck) or die("SELECT TRUCK ".mysql_error());
$row_truck = mysql_fetch_array($result_truck);

$opt_trucker = "";
$opt_trucker .= "<option value=''>--Select a trucker--</option>";
$query_trucker = "SELECT * FROM trucker WHERE is_deleted='0'";
$result_trucker = mysql_query($query_trucker) or die("SELECT TRUCKER ".mysql_error());
while($row_trucker = mysql_fetch_array($result_trucker))
{
	$opt_trucker .= "<option value=".$row_trucker['id'].">".$row_trucker['name']."</option>";
}

$opt_def = "<option value=''>--Select a trucker first--</option>";

$return_str = "<table id='pop_table' border='0' style='margin:25px 25px 0px 25px; padding: 0px auto;width:950px;height:250px;background-color:#FFFFFF;'>
<thead style='height:15%;'>
<tr id='hor-minimalist-b'>
	<th colspan='8'>".$row_trip['tas_number']."&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp;Booking #".$row_trip['booking_number']."</th>
</tr>
</thead>
<tbody>
<tr>
	<td class='label'>Status</td>
	<td class='td_input'><input readonly='readonly' id='txt_status' name='txt_status' type='text' value='".strtoupper($row_trip['status'])."' /></td>
	<td class='label'>Commodity<br />Type</td>
	<td class='td_input'><input readonly='readonly' id='txt_commodity' name='txt_commodity' type='text' value='".$row_trip['commodity_type']."' /></td>
	<td class='label'>Equipment<br />Size</td>
	<td class='td_input'><input readonly='readonly' id='txt_equip_size' name='txt_equip_size' type='text' value='".$row_trip['equipment_size']."' /></td>
	<td class='label'>Equipment<br />Type</td>
	<td class='td_input'><input readonly='readonly' id='txt_equip_type' name='txt_equip_type' type='text' value='".$row_trip['equipment_type']."' /></td>	
</tr>
<tr>
	<td class='label'>Contact Info</td>
	<td class='td_input'><input readonly='readonly' id='txt_contact' name='txt_contact' type='text' value='".$row_trip['contact_info']."' /></td>
	<td class='label'>Positioning<br />Date</td>
	<td class='td_input'><input readonly='readonly' id='txt_position_date' name='txt_position_date' type='text' value='".$row_trip['positioning_date']."' /></td>
	<td class='label'>Positioning<br />Time</td>
	<td class='td_input'><input readonly='readonly' id='txt_position_time' name='txt_position_time' type='text' value='".$row_trip['positioning_time']."' /></td>
	<td class='label'>Receive<br />Date Time</td>
	<td class='td_input'><input readonly='readonly' id='txt_receive' name='txt_receive' type='text' value='".$row_trip['receive_date_time']."' /></td>	
</tr>
<tr>
	<td class='label'>Pickup<br />Address</td>
	<td class='td_input' colspan='3'><textarea readonly='readonly' id='txt_pick' name='txt_pick' cols='40' rows='1'>".$row_trip['pick_address']."</textarea></td>
	<td class='label'>Instruction</td>
	<td class='td_input' colspan='3'><textarea readonly='readonly' id='txt_instruction' name='txt_instruction' cols='40' rows='1'>".$row_trip['instruction']."</textarea></td>
</tr>
</tbody>
</table>";

$return_str .= "<table id='pop_table' border='0' style='margin:0px 25px 25px 25px; padding: 0px auto;width:950px;height:150px;background-color:#FFFFFF;'>
<thead style='height:2%;'>
<tr id='hor-minimalist-b'>
	<th colspan='8'>Trucker Assignment</th>
</tr>
</thead>
<tbody>
<tr>
	<td class='label tflabel'>Trucker</td>
	<td class='td_input tf' ><select id='sel_trucker' name='sel_trucker' onChange=truckerChange(); >".$opt_trucker."</select></td>
	<td class='label tflabel'>Equipment<br />Size</td>
	<td class='td_input tf'><select id='sel_equip_size' name='sel_equip_size' onChange=checkAvailTrucks();>".$opt_def."</select></td>
</tr>
<tr>
	<td class='label tflabel'>Equipment<br />Type</td>
	<td class='td_input tf'><select id='sel_equip_type' name='sel_equip_type' onChange=checkAvailTrucks();>".$opt_def."</select></td>	
	<td class='label tflabel'>Truck</td>
	<td class='td_input tf'><select id='sel_truck' name='sel_truck'>".$opt_def."</select></td>	
</tr>
<tr>
	<td style='text-align:right;' colspan='2'><input onClick='confirmAssignment()'style='width:auto;' type='button' value='Submit' /></td>
	<td style='text-align:left;' colspan='2'><input onClick='closePopDiv()' style='width:auto;' type='button' value='Close' /></td>
</tr>
</tbody>
</table>
<input id='hf_assign_trip_id' name='hf_assign_trip_id' type='hidden' value='".$trip_id."' />";
echo $return_str;
?>